package cs3343.project.family.testing;

import static org.junit.Assert.*;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import cs3343.project.family.*;
import cs3343.project.family.Character;
import cs3343.project.family.UI.GameFrame;

import org.junit.Test;

/**
 * The Class mapTest.
 */
public class mapTest {

	/**
	 * The Class StatisticsControllerStub.
	 */
	class StatisticsControllerStub extends StatisticsController{

		/**
		 * Instantiates a new statistics controller stub.
		 *
		 * @param gc the gc
		 */
		public StatisticsControllerStub(GameController gc) {
			super(gc);
			gc.setStatisticsController(this);
		}
		
		/* (non-Javadoc)
		 * @see cs3343.project.family.StatisticsController#addGameLog(int, java.lang.String)
		 */
		@Override 
		public void addGameLog(int time, String event) {
		}
		
		/* (non-Javadoc)
		 * @see cs3343.project.family.StatisticsController#addplayerLog(cs3343.project.family.Character, java.lang.String)
		 */
		@Override 
		public void addplayerLog(Character player, String event) {
		}
		
	};
	
	/**
	 * The Class GameFrameStub.
	 */
	class GameFrameStub extends GameFrame{

		/**
		 * Instantiates a new game frame stub.
		 *
		 * @param w the w
		 * @param h the h
		 * @param gc the gc
		 */
		public GameFrameStub(int w, int h, GameController gc) {
			super(w, h, gc);
		}
		
		/* (non-Javadoc)
		 * @see cs3343.project.family.UI.GameFrame#setPlayerIconLocation(int)
		 */
		@Override
		public void setPlayerIconLocation(int player) {}
		
	};
	
	/* Test whether move according to dice number
	 * Case : DiceNum=5  currentMap=0
	 * Result: from map zero map 4
	*/	
	/**
	 * Check map id.
	 */
	@Test
	public void checkMapID(){
		
		int diceNum=5;
		int mapSize=20;
		int currentMap=0;
		
		//UI
		GameController gc=new GameController();
		CharacterController cc=gc.getCharacterController();
		StatisticsControllerStub st=new StatisticsControllerStub(gc);
		gc.setStatisticsController(st);
		GameFrameStub gf=new GameFrameStub(0, 0, gc);
		MapController map=new MapController();
		map.setMapSize(mapSize);
		
		//player setting
		String proimgPath = ConfigManager.IMAGE_PATH + "profilePic1" + ".jpg";
        String iconimgPath = ConfigManager.IMAGE_PATH + "char1" + ".jpg";
        String gproimgPath = ConfigManager.IMAGE_PATH + "gprofilePic1" + ".jpg";
        
        Character player = new Character("Player", new ImageIcon(proimgPath),new ImageIcon(gproimgPath), new ImageIcon(iconimgPath));
        cc.addPlayer(player, 0);
        cc.getPlayer(0).setMapAreaId(currentMap);
        
        gf.setPlayerLand(diceNum,player);
        int result=player.getMapAreaId();
        
        assertEquals(result,4); 
	}
	
}
